package com.gxgeek.order.controller;

import com.gxgeek.order.dto.OrderDTO;
import com.gxgeek.order.message.StreamClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @author gaoxing
 * @create 2018-03-28 下午4:33
 */
@RestController
public class SendMessageController {

    @Autowired
    StreamClient client;

    @GetMapping("/sendMessage")
    public void process(){
        Message message = MessageBuilder.withPayload("SpringCloud Stream now: " + new Date()).build();
        client.output().send(message);
    }
    @GetMapping("/sendOrderDTO")
    public void processOrderDTO(){
        OrderDTO orderDTO = new OrderDTO();
        orderDTO.setOrderId("123456");
        Message message = MessageBuilder.withPayload(orderDTO).build();
        client.output().send(message);
    }
}
